/*
 *      Author: Muralidhar Chouhan
 */

#ifndef QUEUE_H_
#define QUEUE_H_

#include <iostream>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
//   Creating a NODE Structure
struct node {
	string data;
	struct node *next;
};

// Creating a class QUEUE
class queue {
	struct node *front, *rear;
	string name;
	int length;
	int i;

public:
	string status;
	queue() // constructure
	{
		front = rear = NULL;
		i=0;
		length=0;
		status="NOT";
	}
	void setName(string n){
		name=n;
	}
	void enqueue(string value); // to insert an element
	string dequeue(); // to delete an element
	void show(); // to show the stack
	int size();
};
int queue::size(){
	return length;
}
// Insertion
void queue::enqueue(string value) {

	struct node *ptr;
	ptr = new node;
	ptr->data = value;
	ptr->next = NULL;
	if (front == NULL)
		front = ptr;
	else
		rear->next = ptr;
	rear = ptr;
	length++;
	status="ITEMS";

}

// Deletion
string queue::dequeue() {
	if (front == NULL) {
		return status;
			}
	struct node *temp;
	temp = front;
	front = front->next;
	cout <<endl<<"Deleted value is " << temp->data<<"from queue"<<name<<endl;
	string ret_data=temp->data;
	delete temp;
	length--;
	if(length==0 && status=="FULL"){
		status="EMPTY";
	}
	return ret_data;

}

// Show Queue
void queue::show() {
	struct node *ptr1 = front;
	if (front == NULL) {
		return;
	}
	while (ptr1 != NULL) {
		cout << ptr1->data << " ->";
		ptr1 = ptr1->next;
	}
}



#endif /* QUEUE_H_ */
